package edu.dayu.controller;

import edu.dayu.pojo.ClubType;
import edu.dayu.service.ClubTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@CrossOrigin
@RequestMapping("/admin")
public class ClubTypeController {
    @Autowired
    private ClubTypeService clubTypeService;

    @PostMapping("/clubTypeList")
    public List<ClubType> clubTypeList(ClubType clubType){
        return clubTypeService.clubTypeList(clubType);
    }

    @PostMapping("/clubTypeInsert")
    public void clubTypeInsert(ClubType clubType){
        clubTypeService.clubTypeInsert(clubType);
    }

    @PostMapping("/clubTypeById")
    public ClubType clubTypeById(ClubType clubType){
        List<ClubType> clubTypes = clubTypeService.clubTypeList(clubType);
        ClubType clubType1 = new ClubType();
        for (ClubType type : clubTypes) {
            clubType1 = type;
        }
        return clubType1;
    }

    @PostMapping("/clubTypeUpdate")
    public void clubTypeUpdate(ClubType clubType){
        clubTypeService.clubTypeUpdate(clubType);
    }

    @PostMapping("/clubTypeDelete")
    public void clubTypeDelete(ClubType clubType){
        clubTypeService.clubTypeDelete(clubType);
    }
}
